package com.xyb.config;

import com.xyb.dao.CourseTopicDao;
import com.xyb.entity.CourseTopic;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 初始化
 */
@Component
public class AdminConfig implements InitializingBean {
    @Resource
    private CourseTopicDao courseTopicDao;

    @Override
    public void afterPropertiesSet() throws Exception {
        //系統初始化 用户
        CourseTopic courseTopic = courseTopicDao.selectCourseTopicByTopicId(0L);
        if (courseTopic == null) {
            CourseTopic topic = CourseTopic.builder()
                    .topicId(0L)
                    .topicName("零基础入门")
                    .showOrder(0)
                    .status(1)
                    .build();
            courseTopicDao.insertCourseTopic(topic);
        }
    }
}










































